package com.cn.shop.controller;

import com.cn.shop.entity.home.Notice;
import com.cn.shop.entity.home.Shop;
import com.cn.shop.service.HomeService;
import com.cn.shop.utils.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/home")
public class HomeController {
    private HomeService homeService;
    @Autowired
    public HomeController(HomeService homeService) {
        this.homeService = homeService;
    }

    /*商家列表*/
    @GetMapping("/shopList")
    public ResultBean<List<Shop>> shopList(String longitude, String latitude){
/*        if(longitude == null || latitude == null){
            throw new CheckException(CHECKMSG.VALIDATE_ARGUMENT_NULL);
        }*/

        return new ResultBean(homeService.getShopLists(longitude,latitude));
    }
    /*公告列表*/
    @GetMapping("/noticeList")
    public ResultBean<List<Notice>> noticeList(){
        return new ResultBean(homeService.getNoticeLists());
    }
}
